//
//  STRewardAlertView.swift
//  iPhone
//
//  Created by Toj on 7/11/23.
//

import UIKit

protocol STRewardAlertViewDelegate: NSObjectProtocol {

}

extension STRewardAlertViewDelegate {
    
}

class STRewardAlertView: UIView {

    weak var delegate: STRewardAlertViewDelegate?
    var admobModel: STAdmobModel? { didSet {
        isHidden = admobModel == nil
        let imageURL = "https://c-ssl.duitang.com/uploads/item/201610/08/20161008181329_SEYWB.jpeg"
        guard let source = URL(string: imageURL) else { return }
        adImageView.kf.setImage(with: source)
    } }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupMakeAddSubviews()
        setupMakeInitialize()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        setupMakeLayoutSubviews()
    }
    
    private(set) lazy var adImageView: UIImageView = {
        let view = UIImageView()
        view.contentMode = .scaleAspectFit
        return view
    }()
}

// MARK: - 点击事件
@objc private extension STRewardAlertView {
    
}

// MARK: - Public
extension STRewardAlertView {
    
}

// MARK: - Private
private extension STRewardAlertView {
    
}

// MARK: - 初始化设置
private extension STRewardAlertView {
    
    func setupMakeAddSubviews() {
        addSubview(adImageView)
    }
    
    func setupMakeLayoutSubviews() {
        adImageView.snp.makeConstraints { make in
            make.edges.equalTo(self)
        }
    }
    
    func setupMakeInitialize() {
        backgroundColor = .random
    }
}
